<template>
  <a-drawer
          :width="drawerWidth"
          @close="handleCancel"
          :visible="visible"
          :confirmLoading="confirmLoading"
  >
    <template  slot="title">
      <div style="width: 100%;">
        <span>{{ title }}</span>
        <span style="display:inline-block;width:calc(100% - 51px);padding-right:10px;text-align: right">
          <a-button @click="toggleScreen" icon="appstore" style="height:20px;width:20px;border:0px"></a-button>
        </span>
      </div>
    </template>

    <a-spin :spinning="confirmLoading" class="drawer-content">
      <a-form :form="form">
          <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="机构名称">
          <a-input autocomplete="off" placeholder="请输入机构编号" v-decorator="['no', {rules:getValidator(true, 100, 1, null, true)} ]"/>
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="机构名称">
          <a-input autocomplete="off" placeholder="请输入机构名称" v-decorator="['name', {rules:getValidator(true, 100, 1, null, false)} ]"/>
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="机构类型"
          :hidden="false">
          <ak-dict-select-tag dict-code="sysOrgType" v-decorator="['orgType', {rules:getValidator(true)} ]" />
        </a-form-item>

        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol"  label="上级机构" v-if="!!model.parentId">
          <ak-tree-select :url="`${url.tree}?_v=${version}`" v-decorator="['parentId', {rules:model.parentId?getValidator(true):[] } ]"/>
        </a-form-item>
        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol"  label="负责人">
          <ak-select-multiple-tag :url="`${SysUserUrl.named}?columns=realname,username&_v=${version}`"  v-decorator="['leaderUsersIds']"/>
        </a-form-item>

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="联系电话">
          <a-input autocomplete="off" placeholder="请输入电话" v-decorator="['mobile',{rules:getValidator(false, 20)}]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="传真">
          <a-input autocomplete="off" placeholder="请输入传真" v-decorator="['fax', ,{rules:getValidator(false, 50)}]"  />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="地址">
          <a-input autocomplete="off" placeholder="请输入地址" v-decorator="['address', ,{rules:getValidator(false, 200)}]"  />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="排序">
          <a-input-number v-decorator="[ 'sort',{'initialValue':0, rules:getValidator(true)}]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="备注">
          <a-textarea placeholder="请输入备注" v-decorator="['memo', {rules:getValidator(false,200)}]"  />
        </a-form-item>

      </a-form>
    </a-spin>
    <div class="drawer-bootom-button" v-show="!disableSubmit">
      <a-popconfirm title="确定放弃编辑？" @confirm="handleCancel" okText="确定" cancelText="取消">
        <a-button style="margin-right: .8rem">取消</a-button>
      </a-popconfirm>
      <a-button @click="handleSubmit" type="primary" :loading="confirmLoading">提交</a-button>
    </div>
  </a-drawer>
</template>

<script>

  import {sysDepartUrl, SysUserUrl} from '../../../api/url';
  import AkfhModelDrawMixin from '../../../mixin/AkfhModelDrawMixin'
  import AkDictSelectTag from "../../../components/akfh/AkDictSelectTag";
  import AkTreeSelect from "../../../components/akfh/AkTreeSelect";
  import AkSelectMultipleTag from '../../../components/akfh/AkSelectMultipleTag.vue';
  export default {
    name: "SysDepartModal",
    components: {AkTreeSelect, AkDictSelectTag, AkSelectMultipleTag},
    mixins:[AkfhModelDrawMixin],
    data () {
      return {
        url: sysDepartUrl,
        SysUserUrl:SysUserUrl,
        entity:'SysDepartEntity'
      }
    },
    mounted () {
    },
    methods: {
    }
  }
</script>

<style scoped>

</style>
